package com.javabasic.algorithm.sword_of_offer;

/**
 * @author mir.xiong
 * @version 1.0
 * @description
 * @see
 * @since Created by work on 2022/1/10 11:19 下午
 */
public class 剑指_Offer_11_旋转数组的最小数字 {

    public int minArray(int[] numbers) {
        int len = numbers.length;
        if (len == 1) {
            return numbers[0];
        }
        if (numbers[0] >= numbers[len-1]) {
            int result = numbers[len-1];
            for (int i = len-1; i >= 0; i--) {
                if (numbers[i] <= result) {
                    result = numbers[i];
                } else {
                    break;
                }
            }
            return result;
        } else {
            return numbers[0];
        }
    }
}
